package com.zhuqi.util;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.zhuqi.domain.UriExcel;
import lombok.Data;

import java.util.HashMap;
import java.util.concurrent.atomic.LongAdder;

/**
 * @author : ZhuQi
 * @version : 时间:2022/8/9 14:39 版本:
 */
@Data
public class UrlReadListener extends AnalysisEventListener<UriExcel> {

    private HashMap<String, LongAdder> map;


    public UrlReadListener(HashMap<String, LongAdder> map) {
        this.map = map;
    }

    /**
     * When analysis one row trigger invoke function.
     *
     * @param data    one row value. Is is same as {@link AnalysisContext#readRowHolder()}
     * @param context
     */
    @Override
    public void invoke(UriExcel data, AnalysisContext context) {
        map.put(data.getUri(), new LongAdder());
    }

    /**
     * if have something to do after all analysis
     *
     * @param context
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }
}
